<template>
  <div id="app">
    <h3 class="center">欢迎光临vue开发的收银系统水果店</h3>
    <table class="tb">
      <tr>
        <td><b>苹果 10 ¥ / 斤,折扣 &lt;8折&gt;</b></td>
      </tr>
      <tr>
        <td>请输入你要买的斤数<input type="text" v-model.number="buyFn" /></td>
      </tr>
      <tr>
        <td><button @click="btn">结账买单</button></td>
      </tr>
      <tr>
        <td>
          结账单:总价:{{ totolPrice }} ¥元 折后价: {{ discountPrice }} ¥元 省了:
          {{ savePrice }} ¥元
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      buyFn: 0,
      totolPrice: 0,
      discountPrice: 0,
      savePrice: 0,
    };
  },
  methods: {
    btn() {
      this.totolPrice = this.buyFn * 10;
      this.discountPrice = this.totolPrice * 0.8;
      this.savePrice = this.totolPrice - this.discountPrice;
    },
  },
};
</script>

<style scoped>
#app {
  width: 600px;
  margin: 10px auto;
}
.tb {
  border-collapse: collapse;
  width: 100%;
}

.tb th {
  background-color: #0094ff;
  color: white;
}

.tb td,
.tb th {
  padding: 5px;
  border: 1px solid black;
  text-align: center;
}
.center {
  text-align: center;
}
</style>>
